package com.itheima.day04.ZuoYe.ZuoYe5;

import com.itheima.day04.objects.Stringjoiner;

import java.util.StringJoiner;

public class Test {
    public static void main(String[] args) {
        StringB();
        StringJ();
        StringBuffer B = new StringBuffer();
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
            B.append(i);
            i++;
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);

    }

    private static void StringJ() {
        StringJoiner Sj = new StringJoiner("");
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
            Sj.add(i+"");
            i++;
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    private static void StringB() {
        StringBuilder sb = new StringBuilder();
        long start =System.currentTimeMillis() ;
        for (int i = 0; i < 1000000; i++) {
            sb.append(i);
            i++;
        }
        long end =System.currentTimeMillis() ;
        System.out.println(end-start);
    }
}
